package com.xuexi.demos.Config;

import com.xuexi.demos.utils.JwtInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class JwtInterceptorConfig implements WebMvcConfigurer {
    @Autowired
    private JwtInterceptor jwtInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(jwtInterceptor)
                .addPathPatterns("/api/**")
                // 修复：使用正确的排除路径模式
                .excludePathPatterns(
                        "/api/user/login",      // 登录接口
                        "/api/user/register",   // 注册接口
                        "/api/user/wxlogin",    // 微信登录接口
                        "/api/open/**"          // 开放接口
                );
    }
}